package com.system.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.system.demo.entity.auth.UserRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserRoleMapper extends BaseMapper<UserRole> {

    @Select("SELECT role_id FROM user_role WHERE uid = #{uid}")
    List<Integer> findRoleIdsByUid(String uid);

    @Select("<script>" +
            "SELECT id FROM user_role WHERE uid IN " +
            "<foreach item='item' index='index' collection='uids' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>")
    List<Integer> selectIdsByUids(@Param("uids") List<String> uids);
}
